<?php $this->assign('subtitle', 'Adicionar novo usuário'); ?>

<div class="row content-view">

    <div class="col-md-10 col-md-offset-1">

        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title text-info">Novo Usuário</h3>
            </div>
            <form role="form" method="POST" class="form-horizontal">
                <div class="panel-body">
                    <fieldset class="form-panel">
                        <div class="col-md-5">
                            <div class="form-group <?php echo isset($errors['username']) ? 'has-error' : ''; ?>">
                                <label class="control-label required" for="username">Login:</label>
                                <input autofocus class="form-control" name="username" id="username" value="<?php echo $user['username']; ?>" />
                                <?= $this->element('field_errors', [ "errors" => $errors, 'field' => 'username']); ?>
                            </div>

                            <div class="form-group <?php echo isset($errors['rawpassword']) ? 'has-error' : ''; ?>">
                                <label class="control-label required" for="password">Login:</label>
                                <input class="form-control" type="password" name="password" id="password" />
                                <?= $this->element('field_errors', [ "errors" => $errors, 'field' => 'rawpassword']); ?>
                            </div>

                            <div class="form-group <?php echo isset($errors['role']) ? 'has-error' : ''; ?>">
                                <label class="control-label required" for="role">Role:</label>
                                <select class="form-control" name="role" id="role">
                                    <option value=""></option>
                                    <option <?= $user['role'] == 'admin' ? "selected" : ""; ?> value="admin">Administrador</option>
                                    <option <?= $user['role'] == 'focal' ? "selected" : ""; ?>  value="focal">Focal</option>
                                    <option <?= $user['role'] == 'publicador' ? "selected" : ""; ?>  value="publicador">Publicador</option>
                                </select>
                                <?= $this->element('field_errors', [ "errors" => $errors, 'field' => 'role']); ?>
                            </div>
                            <div class="form-group">
                                <input type="submit" autofocus class="btn btn-info" value="Cadastrar" />
                            </div>
                        </div>
                    </fieldset>
            </form>
        </div>

    </div>
</div>
</div>
